package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class PermServiceImpl implements PermService {
    @Autowired
    private DtsPermissionMapper dtsPermissionMapper;

    @Override
    public Set<String> queryPermByRoleIds(Integer[] roleIds) {
        QueryWrapper<DtsPermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("role_id",roleIds);
        List<DtsPermission> list = dtsPermissionMapper.selectList(queryWrapper);
        HashSet<String> set = new HashSet<>();
        for (DtsPermission dtsPermission : list) {
            set.add(dtsPermission.getPermission());
        }
        return set;
    }
}
